package com.sjq.common.service.impl;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.sjq.common.dao.RoleDao;
import com.sjq.common.entity.Role;
import com.sjq.common.exception.ServiceException;
import com.sjq.common.service.RoleService;
import com.sjq.common.util.PageResults;

@Service("roleService")
public class RoleServiceImpl implements RoleService{
	
	@Autowired
	private RoleDao roleDao;
	
	@Override
	public PageResults<?> findRoleByPage(int pageNo, int pageSize, Role role) throws ServiceException {
		PageResults<?> pageResults=roleDao.selectRoleByPage(pageNo, pageSize, role);
		return pageResults;
	}
	//查询所有
	@Override
	public PageResults<?> selectAllRole() throws ServiceException {
		PageResults<?> pageResults=roleDao.selectAllRole( );
		return pageResults;
	}

	@Override
	public void addRole(Role role) {
		if(role==null){
			return;
		}
		roleDao.insertRole(role);
	}

	@Override
	public Map<String, Object> findSingleRole(int role_id) throws ServiceException {
		Map<String, Object> role=roleDao.selectSingleRole(role_id);
		return role;
	}

	@Override
	public void removeRole(int role_id) {
		roleDao.deleteRole(role_id);
	}

	@Override
	public void modifyRole(Role role) {
		if(role==null){
			return;
		}
		roleDao.updateRole(role);
	}

	@Override
	public int referenceRole(int role_id) {
		return roleDao.judge(role_id);
	}

}
